package com.neuedu.springjdbc;

import com.alibaba.druid.pool.DruidDataSource;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.jdbc.core.JdbcTemplate;

import javax.sql.DataSource;

@Configuration
public class AppConfig {


    @Bean
    DataSource getDataSource(){

        DruidDataSource datasource = new DruidDataSource();
        datasource.setUsername("root");
        datasource.setPassword("root");
        datasource.setUrl("jdbc:mysql://127.0.0.1:3306/mybatis");
        datasource.setDriverClassName("com.mysql.jdbc.Driver");

        //其他配置
        //datasource.set
        return datasource;
    }

    @Bean
    JdbcTemplate getJdbcTemplate(DataSource dataSource ){
        JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
        return jdbcTemplate;
    }


}
